#pragma once
#include"comLib\VideoInf.h"
#include<memory>
#include"comLib\global.h"
extern "C" {
#include<libavcodec\avcodec.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
}

class RPCFW_EXPORT CVideoDecoder :public DecoderInf
{
public:
	CVideoDecoder(const AVCodecID id = AV_CODEC_ID_H264, const AVPixelFormat pixFormat = AV_PIX_FMT_YUV420P);
	~CVideoDecoder();
	AVFrame *decode(uint8_t *data, int size);
	int decodePkt(AVPacket *, const FrameCallback &) override;

private:
	int decodeParsePkt(const AVPacket *, const FrameCallback &);

private:
	AVCodecParserContext *m_pCodecParContext;
	AVCodecContext *m_pCodecContext;
	SwsContext *m_pSwsContext;
	AVPacket *m_pPkt;
	AVFrame *m_pFrame;
};

